﻿Imports System
Imports System.Collections.Generic
Imports System.drawing.printing


Public Class ZebraPrinters
    Public Function InstalledPrinters() As IList(Of String)
        Return ToSortedStringArray(PrinterSettings.InstalledPrinters)
    End Function

    Public Function DefaultZebraPrinter() As String
        For Each printer As String In InstalledPrinters()
            If Not String.IsNullOrEmpty(printer) AndAlso printer.ToUpper().Contains("ZEBRA") Then
                Return printer
            End If
        Next
        Return Nothing
    End Function

    Private Function ToSortedStringArray(printers As PrinterSettings.StringCollection) As IList(Of String)
        Dim stringList As New List(Of String)()
        For Each printer As String In printers
            stringList.Add(printer)
        Next
        stringList.Sort(StringComparer.Ordinal)
        Return stringList
    End Function
End Class
